
import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

// import indexPage from '../views/index.vue'
// import loginPage from '../views/login.vue'
// const Home = { template: '<div>Home</div>' }
// const About = { template: '<div>About</div>' }

const routes = [
    { path: '/', redirect: '/index'},
    { 
      path: '/index', 
      component:() => import('../views/index'),
      redirect:'/index/banners',
      meta: { title:'首页' },
      children: [
        { path: 'banners',meta: { title:'轮播图管理' }, component:() => import('../views/shouye/banner') },
        { path: 'category',meta: { title:'分类管理' }, component:() => import('../views/shouye/category') },
        { path: 'recomend',meta: { title:'为您推荐管理' }, component:() => import('../views/shouye/recomend') }
        // { path: 'fengnei', component:() => import('../views/shangpin/fennei') },
        // { path: 'pinpai', component:() => import('../views/shangpin/pinpai') },
        // { path: 'shangpin', component:() => import('../views/shangpin/shangpin') },
        // { path: 'xinwen', component:() => import('../views/xinwen/xinwen') }
      ]
    },
    { path: '/login', component:() => import('../views/login') },
]

const router = new VueRouter({
    routes//`routes: routes` 的缩写
})

router.beforeEach((to,from,next) => {
  console.log(to,from)
  next()
})

export default router